from invidious import Channel as channel

from src.vobjects.item import Item

from src.utils import *

class BaseChannel(channel):

    def to_item(self):
        if len(self.latestVideos) > 0:
            last_video_time = f"({self.latestVideos[0].publishedText})"
        else:
            last_video_time = f"No videos"
        views = f"{convert_big_nums(self.totalViews)} views"
        subs = f"{convert_big_nums(self.subCount)} subs"

        status = {
            "url" : self.authorUrl
        }

        return Item(self.author, views, subs, last_video_time, self, status=status)

